package org.example.spring.utils;

import org.springframework.transaction.TransactionStatus;

/**
 * LuoYu
 * 2022/12/13 18:55
 **/
public class TransactionThreadHolder {

    private final static ThreadLocal<TransactionStatus> threadHolder = new ThreadLocal<>();


    public static void add(TransactionStatus status) {
        threadHolder.set(status);
    }

    public static TransactionStatus get() {
        return threadHolder.get();
    }

    public static void remove() {
        threadHolder.remove();
    }


    public static boolean hasExist() {
        return get() != null;
    }
}
